<? if (empty($cantCreate)): ?>
<p><?= $this->Html->link('+New', array('action'=>'create')) ?></p>
<? endif ?>

<table>
<tr>
    <? foreach ($fields as $label=>$key): ?>
    <th><?= $label ?></th>
    <? endforeach ?>
    <? if(empty($cantEdit)): ?>
    <th></th>
    <? endif ?>
</tr>
<? foreach ($data as $row): ?>
<?php
    $id    = $row[$entity]['id'];
?>
<tr>
    <? foreach ($fields as $label=>$value): ?>
    <td>
        <? if(is_callable($value)): ?>
            <?= $value($row) ?>
        <? else: ?>
            <?= Set::extract($value, $row) ?>
        <? endif ?>
    </td>
    <? endforeach ?>
    <? if(empty($cantEdit)): ?>
    <td>
        <?= $this->Html->link('edit', array('action'=>'edit', $id)) ?> |
        <?= $this->Html->link('delete', array('action'=>'delete', $id), array('confirm'=>'Do you wanna delete?')) ?>
    </td>
    <? endif ?>
</tr>
<? endforeach ?>
</table>